package cn.school.web;

import cn.school.entity.Page;
import cn.school.entity.Subject;
import cn.school.service.SubjectService;
import cn.school.util.StringUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
@WebServlet(name = "SubjectServlet",value = "/subjectServlet")
public class SubjectServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int pageNo= StringUtil.toIntGt0(req.getParameter("pageNo"),1);//Integer.valueOf(req.getParameter("pageNo"));
        int pageSize= StringUtil.toIntGt0(req.getParameter("pageSize"),10);
        Page<Subject> p = SubjectService.INST.search(pageNo, pageSize);
        req.setAttribute("p",p);
        req.getRequestDispatcher("/WEB-INF/jsp/subjects2.jsp").forward(req,resp);
    }
}
